import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //
        Main test = new Main();
        test.mmain();
    }
}


// 注意类名必须为 Main, 不要有任何 package xxx 信息
class Main {
    public static void mmain() {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();

        int[][] nums = new int[n+1][m+1];
        int[][] dp = new int[n+1][m+1];

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                nums[i][j] = in.nextInt();
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + nums[i][j];
            }
        }

        int[][] searchFor = new int[q][4];
        for(int i = 0, j = 0; i <q; i++){
            for(j = 0; j < 4; j++){
                searchFor[i][j] = in.nextInt();
            }
            int left_up_1 = searchFor[i][0];
            int left_up_2 = searchFor[i][1];//前缀和数组的左上角下标
            int right_down_1 = searchFor[i][2];
            int right_down_2 = searchFor[i][3];//前缀和数组的右下角下标
            int A = dp[left_up_1-1][left_up_2 - 1];
            int B = dp[right_down_1][left_up_2 - 1];
            int C = dp[left_up_1-1][right_down_2 - 1];
            int D = dp[right_down_1][right_down_2];

            int result = D - B - C + A  ;
            System.out.println(result);
        }
        System.out.println("finished!!!");

    }
}
//3 //4 //3 //1 //2 //3 //4 //4 //3 //2 //1 //1 //5 //6 //7 //1 //1 //2 //2